home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / BUSINESS / STATA3.LZH / GRAPHKIT.TUT < prev    next >
Text File  |  1988-08-29  |  9KB  |  271 lines

  1. set output error
  2. set display page 23
  3. set more 1
  4. #delimit ;
  5.  
  6. di _n(13) in wh
  7. "  ___  ____  ____  ____  ____ tm" _n
  8. " /__    /   ____/   /   ____/" _n
  9. "___/   /   /___/   /   /___/    Graph.Kit:  Programmed Extensions to Stata" _n
  10. "--------------------------------------------------------------------------"
  11. _n(2) ;
  12.  
  13. di in gr
  14. "Graph.Kit is a collection of programs written in Stata that provides a conven-"
  15. _n
  16. "ient way of creating a variety of statistical graphs.  Although Graph.Kit is"
  17. _n
  18. "written in Stata's programming language, you do not have to know anything" _n
  19. "about the programming language to use Graph.Kit." _n ;
  20.  
  21. di in gr
  22. "If your computer and monitor do not have graphics capabilities, there is no" _n
  23. "reason to run this tutorial.  You can still use Stata's graphics, but you will"
  24. _n
  25. "have to print them in order to see them.  This tutorial assumes that you will"
  26. _n
  27. "be able to see the graphs as we draw them.  You can abort this tutorial by" _n
  28. "pressing "
  29. in wh "Break"
  30. in gr " (DOS users hold down "
  31. in wh "Ctrl" in gr " and press " in wh "Break"
  32. in gr ", Unix users hold down"
  33. _n
  34. in wh "Ctrl" in gr " and press " in wh "C"
  35. in gr ").  On the next screen, we will verify that Stata thinks your"
  36. _n
  37. "computer has graphics capabilities." _n ;
  38.  
  39. di in gr
  40. "If you are using a Sun under SunView, please "
  41. in wh "Break" in gr" out of this tutorial, type"
  42. _n
  43. "'" in wh "window define tut"
  44. in gr "', and then restart this tutorial.  You don't have to do" _n
  45. "that, but results will be better if you do.  (You may have already done this"
  46. _n
  47. "when you ran the graphics tutorial.  If so, you don't need to do it again.)"
  48. _n ;
  49.  
  50.  
  51.  
  52. #delimit cr
  53. mac def path
  54. capture run nullfile.tut
  55. if _rc {
  56.     mac def path "\stata\"
  57.     capture run %path`nullfile.tut
  58.     if _rc {
  59.         mac def path "/usr/stata/"
  60.         capture run %path`nullfile.tut
  61.         if _rc {
  62.             #delimit ;
  63.             di in red
  64. "I cannot find the other tutorial files.  I have looked in the current" _n
  65. "directory and in \stata (DOS) or /usr/stata (Unix).  Is Stata installed" _n
  66. "correctly?" _n(2)
  67. "In any case, I cannot run the tutorial." ;
  68.             #delimit cr
  69.             exit
  70.         }
  71.     }
  72. }
  73. macro define F5 "do %path`contents.tut;"
  74. macro define F6 "do %path`datakit.tut;"
  75. drop _all
  76. label drop _all
  77. set textsize 100
  78. if "%path"=="/usr/stata/" {
  79.     mac def _pause "more"
  80. }
  81. #delimit ;
  82. set more 0 ; more ; set more 1 ;
  83.  
  84. di _n(4) in wh
  85. "More preliminary" _n
  86. "----------------" _n(2)
  87. ". query" ;
  88. noisily query ;
  89.  
  90. di in gr _n
  91. "If the above display indicates that "
  92. in wh "graphics" in gr " are " in wh "off"
  93. in gr ", Stata does not think" _n
  94. "your computer and monitor have graphics capabilities, so you may as well" _n
  95. in wh "Break" in gr " out of this tutorial." _n ;
  96.  
  97. set more 0 ; more ; set more 1;
  98. macro define F6 "do %path`graphkit.tut;" ;
  99.  
  100.  
  101. di _n(10) in wh
  102. "Loading Graph.Kit" _n
  103. "-----------------" _n ;
  104.  
  105. di _n(2) in wh _dup(79) "-" _n in gr
  106. "Before you can use Graph.Kit, you must load it:" _n
  107. in wh _dup(79) "-" _n(4)
  108. ". run %path`Graph.Kit" ;
  109. run %path`Graph.Kit ;
  110. di _n ; set more 0 ; more ; set more 1 ;
  111.  
  112. di _n(2) in wh
  113. "Overview" _n
  114. "--------" _n ;
  115.  
  116. di in gr
  117. "Graph.Kit adds seven new commands to Stata:" _n(2)
  118. _col(8) in wh "grebar" _col(20) in gr "error-bar chart" _n
  119. _col(8) in wh "leverage" _col(20) in gr "partial-regression leverage plot" _n
  120. _col(8) in wh "quantile" _col(20) in gr "quantile plot" _n
  121. _col(8) in wh "qnorm" _col(20) in gr "quantile-normal plot" _n
  122. _col(8) in wh "qqplot" _col(20) in gr "quantile-quantile plot" _n
  123. _col(8) in wh "symplot" _col(20) in gr "symmetry plot" _n ;
  124.  
  125. di in gr
  126. "We were forced to omit the "
  127. in wh "grebar" in gr " command from the demonstration version of" _n
  128. "Graph.Kit.  During the process of making its calculations, "
  129. in wh "grebar" in gr " writes a" _n
  130. "temporary data set, something the demonstration version of Stata cannot do."
  131. _n
  132. "If you attempt to use "
  133. in wh "grebar" in gr ", you will get the message '" in ye "not available in" _n
  134. "demonstration version" in gr "'."  _n(2)
  135. "If you are using the Unix version of Stata in demonstration mode, do not use"
  136. _n
  137. "the "
  138. in wh "grebar" in gr
  139. " command.  Your version of Graph.Kit contains the real " in wh "grebar" _n
  140. in gr
  141. "program, but it will not work in demonstration mode." _n(3) ;
  142. set more 0 ; more ; set more 1 ;
  143.  
  144. di _n(2) in wh _dup(79) "-" _n in gr
  145. "We begin by using our automobile data, the same data we used in the introduc-"
  146. _n
  147. "tion.  We only need a few of the variables:" _n
  148. in wh _dup(79) "-" _n(2)
  149. ". use %path`auto, clear" ;
  150. use %path`auto, clear ;
  151. di _n in wh ". keep make price mpg weight displ foreign" _n(2)
  152. ". describe" ;
  153. keep make price mpg weight displ foreign;
  154. noisily describe ;
  155. di _n in wh ". list in 1/20" ;
  156. set more 0 ; more ; set more 1 ;
  157. noisily list in 1/20 ;
  158. set more 0 ; more ; set more 1 ;
  159.  
  160. di _n(17) in wh _dup(79) "-" _n
  161. "hilite" in gr
  162. " is a convenient command for drawing two-way scatterplots and highlight-"
  163. _n
  164. "ing a subset of the data.  Its syntax is the same as "
  165. in wh "graph" in gr "'s " in wh "twoway" in gr " syntax,"
  166. _n
  167. "except that you must specify the group to be highlighted:" _n
  168. in wh _dup(79) "-" _n(2)
  169. ". hilite mpg displ, hilite(foreign) ylabel xlabel" ;
  170. set more 0 ; more ;
  171. hilite mpg displ, hilite(foreign) ylabel xlabel sy(pO) gap(5) ;
  172. %_pause ; set more 1 ;
  173.  
  174. di _n(2) in wh _dup(79) "-" _n in gr
  175. "The "
  176. in wh "leverage" in gr
  177. " command produces partial-regression leverage plots.  Its syntax" _n
  178. "is '" in wh "leverage" in gr
  179. " lhsvar rhsvar1 rhsvar2 rhsvar3 ...'.  The command graphs lhsvar" _n
  180. "against rhsvar1 after making them orthogonal to rhsvar2, rhsvar3, and so on."
  181. _n(2)
  182. "Consider the model" _n(2)
  183. _col(8) "mpg = b  + b displ + b weight + b foreign" _n
  184. _col(8) "       0    1         2          3" _n ;
  185.  
  186. di in gr
  187. "To obtain the regression estimates, we could type '"
  188. in wh "regress mpg displ weight" _n
  189. "foreign" in gr "' or '" in wh
  190. "regress mpg foreign weight displ" in gr "' -- the order of the right-hand-"
  191. _n
  192. "side variables makes no difference -- it is still the same model.  To obtain"
  193. _n
  194. "the partial-regression leverage plot for weight -- corresponding to b2 -- we"
  195. _n
  196. "type either '"
  197. in wh "leverage mpg weight foreign displ" in gr "' or '" in wh
  198. "leverage mpg weight displ"
  199. _n
  200. "foreign" in gr "
  201. ' -- we must make weight the first right-hand-side variable." _n(2)
  202. "To obtain the leverage plot for foreign -- corresponding to b3 -- we could" _n
  203. "type:" _n
  204. in wh _dup(79) "-" _n(3)
  205. ". leverage mpg foreign displ weight" ;
  206. set more 0 ; more ;
  207. leverage mpg foreign displ weight ;
  208. %_pause ; set more 1 ;
  209.  
  210. di _n(2) in wh _dup(79) "-" _n in gr
  211. "We are sometimes interested in whether a variable has a symmetric "
  212. "distribution." _n
  213. "Symmetry plots focus on this aspect of a distribution." _n(2)
  214. "The most expensive car in our 1978 automobile data costs "
  215. in ye "$15,906" in gr "; the least" _n
  216. "expensive costs " in ye "$3,291" in gr
  217. ".  Let's compare these two cars with the typical car in" _n
  218. "the data, comparing how much more it costs to buy the most expensive car with"
  219. _n
  220. "how much less it costs to buy the least expensive.  If the automobile price" _n
  221. "distribution is symmetric, the price differences would be almost the same."
  222. _n ;
  223.  
  224. di in gr
  225. "The price of the median car in our data is "
  226. in ye "$5,006.50" in gr ", so the most expensive"
  227. _n
  228. "car costs "
  229. in ye "$10,899.50" in gr
  230. " more than the median car and the least expensive costs" _n
  231. in ye "$1,715.50" in gr
  232. " less than the median car.  We now have one piece of evidence that"
  233. _n
  234. "the distribution is not symmetric." _n ;
  235.  
  236. di in gr
  237. "We could repeat the calculation for the second most expensive car and the sec-"
  238. _n
  239. "ond least expensive car, then for the third, and so on.  "
  240. in wh "symplot" in gr" makes these"
  241. _n
  242. "calculations and graphs the result:" _n
  243. in wh _dup(79) "-" _n(5)
  244. ". symplot price" ;
  245. set more 0 ; more ;
  246. symplot price ;
  247. %_pause ; set more 1 ;
  248.  
  249.  
  250. drop _all ;
  251. label drop _all ;
  252. macro define F6 "do %path`datakit.tut;" ;
  253.  
  254. di _n(4) in white
  255. "Demonstration ends" _n
  256. "------------------" _n ;
  257.  
  258.  
  259. di in green
  260. "That concludes our short demonstration, but there's much more.  We now return"
  261. _n
  262. "control to you.  Some suggestions:" _n ;
  263.  
  264. di in green
  265. "If you ..." _col(34) "Then we will show you ..." _n
  266. "    Press " in white "F5" in green _col(38) "a table of tutorial contents" _n
  267. "    Press " in white "F6" in green _col(38) "the next tutorial, "
  268. in white "datakit.tut" _n ;
  269.  
  270. run %path`tobuy.tut ;
  271.